﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Exe1
{
    public partial class FrmAdd : Form
    {
        public Form1 frmPa;
        public int mode;
        public FrmAdd()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            itm vNew;
            if (mode==0)
            {
                // 获取当前行索引
                int curR = frmPa.grdPapers.Rows.Count - 1;
                // 将数据写入到我们自己的数据容器中 
                vNew.title = tbxTitle.Text;
                vNew.authors = tbxAuthor.Text;
                vNew.zhaiyao = tbxAbstract.Text;
                frmPa.m_vPapars.add(vNew);


                frmPa.reloadData();
            } 
            else
            {
                int curR = frmPa.grdPapers.CurrentRow.Index ;
                // 修改自己的数据容器中的值
                vNew.title = tbxTitle.Text;
                vNew.authors = tbxAuthor.Text;
                vNew.zhaiyao = tbxAbstract.Text;

                frmPa.m_vPapars.set(curR, vNew);;                
                // 更新界面

                frmPa.reloadData();
            }
            
        }
    }
}
